package cn.com.dcsgo.exception;

import cn.com.dcsgo.result.ResultCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 自定义异常类
 *
 * @author Dcsgo
 * @since 2025/3/17 16:47
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class UuPreferredException extends RuntimeException{
    /**
     * 异常状态码
     */
    private final Integer code;

    /**
     * 通过状态码和错误消息创建异常对象
     * @param message message
     * @param code code
     */
    public UuPreferredException(String message, Integer code) {
        super(message);
        this.code = code;
    }

    /**
     * 接收枚举类型对象
     * @param resultCodeEnum resultCodeEnum
     */
    public UuPreferredException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }

    @Override
    public String toString() {
        return "UuPreferredException{" +
                "code=" + code +
                '}';
    }
}
